 package ac.zlf.springmybatis.core.util.security;
 
 import ac.zlf.core.util.encode.Encodes;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.util.UUID;
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
 
 public class AuthenticationKey
 {
   private String secretToken;
   private String signatureKey;
   
   public AuthenticationKey(String secretToken, String signatureKey)
   {
     this.secretToken = secretToken;
     this.signatureKey = signatureKey;
   }
   
   public static AuthenticationKey generateAuthenticationKey()
   {
     String uuid = UUID.randomUUID().toString();
     String secretToken = null;
     String signatureKey = null;
     try
     {
       MessageDigest digest = MessageDigest.getInstance("SHA1");
       digest.update(uuid.getBytes());
       secretToken = Encodes.encodeBase64(digest.digest());
     }
     catch (NoSuchAlgorithmException e) {}
     SecureRandom random = new SecureRandom(UUID.randomUUID().toString().getBytes());
     try
     {
       KeyGenerator keyGenerator = KeyGenerator.getInstance("DES");
       keyGenerator.init(random);
       SecretKey key = keyGenerator.generateKey();
       signatureKey = Encodes.encodeBase64(key.getEncoded());
     }
     catch (NoSuchAlgorithmException e) {}
     return new AuthenticationKey(secretToken, signatureKey);
   }
   
   public String getSecretToken()
   {
     return this.secretToken;
   }
   
   public void setSecretToken(String secretToken)
   {
     this.secretToken = (secretToken == null ? null : secretToken.trim());
   }
   
   public String getSignatureKey()
   {
     return this.signatureKey;
   }
   
   public void setSignatureKey(String signatureKey)
   {
     this.signatureKey = (signatureKey == null ? null : signatureKey.trim());
   }
 }



/* Location:           D:\repository\cc\hwtech\core\2.0.1-school-SNAPSHOT\core-2.0.1-school-SNAPSHOT.jar

 * Qualified Name:     AuthenticationKey

 * JD-Core Version:    0.7.0.1

 */
